import 'package:flutter/material.dart';

class SwordPath extends CustomClipper<Path> {
  @override
  getClip(Size size) {
    print(size);
    // 获取视图的大小
    double w = size.width;
    double h = size.height;
    // 月牙上边界的高度
    double topH = h * 0.92;
    Path path = new Path();
    // 以区域中点开始绘制
    path.moveTo(0, h / 2);
    // 贝塞尔曲线连接path
    path.cubicTo(0, topH * 3 / 4, w / 4, topH, w / 2, topH);
    path.cubicTo((3 * w) / 4, topH, w, topH * 3 / 4, w, h / 2);
    path.cubicTo(w, h * 3 / 4, 3 * w / 4, h, w / 2, h);
    path.cubicTo(w / 4, h, 0, h * 3 / 4, 0, h / 2);
    return path;
  }

  @override
  bool shouldReclip(covariant CustomClipper oldClipper) => false;
}
